<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #n3 {
            width: 50px;
            text-align: center;
            border: 0;
        }

        #box1 {
            width: 200px;
            height: 200px;
            background-color: #000000;
        }
    </style>
</head>

<body>
    <!-- ## 1. 斐波那契数列

    ```javascript
    1 1 2 3 5 8 13 21.......
    推导公式：fib(m) = fib(m-1) + fib(m-2)
    ```

    ## 2.验证码匹配的问题

    ## 3.封装一个十六进制的随机颜色 函数 #fff111 -->
    <p>第一题:</p>
    <input type="number" id="n1">
    <button id="btn1">计算</button>
    <p>第二题 验证码：</p>
    请输入你的验证码: <input type="text" id="n2">验证码为：<button id="n3"></button> <br>
    <button id="n4">验证</button><span id="p1"></span><br>
    <button id="n5">改变背景颜色</button>
    <div id="box1"></div>
    <script src="../js/until.js"></script>
    <script>
        window.onload = () => {
            btn1.onclick = () => {
                // console.log("a");
                let fibbefore = 1;
                let fibbef = 1;
                let num = "1 1 ";

                if (n1.value <= 2) {
                    console.log("请输入3或3以上的值")
                } else {
                    for (let i = 1; i <= n1.value - 2; i++) {
                        let fib = fibbef + fibbefore;
                        num = num + fib + " "
                        if (i % 2 == 0) {
                            fibbefore = fib;
                        } else if (i % 2 != 0) {
                            fibbef = fib;
                        }
                    }
                }
                console.log(num);
            }

            //第二题
            let shuiji = () => {
                return parseInt(Math.random() * 10) + "" + parseInt(Math.random() * 10) + "" + parseInt(Math.random() * 10) + "" + parseInt(Math.random() * 10)
            }
            n3.innerHTML = shuiji();
            n3.onclick = () => {
                console.log("a");
            }
            n4.onclick = () => {
                if (n2.value == n3.innerHTML) {
                    p1.innerHTML = "正确"
                }
                else {
                    p1.innerHTML = "错误"
                }
            }


            //第三题

            // sixteen();
            n5.onclick = () => {
                let bg = "#" + sixteen();
                // console.log(bg);
                // body.style.background = bg;
                box1.style.background = bg;
            }
        } </script>


</body>


</html>